import {
	getPositionList,
	startPosition,
	updatePosition,
	deletePosition,
	addPosition,
	getPosition
} from '@/api/index'

const state = {
	positionList: []
}

const mutations = {
	getPositionList(state, data){
		state.positionList = data
	}
}

const actions = {
	// 选择框获取岗位列表
	async getPosition({commit}){
		let res = await getPosition()
		return res
	},
	// 获取岗位列表
	async getPositionList({commit}){
		let res = await getPositionList()
		commit('getPositionList', res.data)
		return res
	},
	// 启用和禁用
	async startPosition({commit}, data){
		let res = await startPosition(data)
		return res
	},
	// 修改岗位名称
	async updatePosition({commit}, data){
		let res = await updatePosition(data)
		return res
	},
	// 删除岗位名称
	async deletePosition({commit}, data){
		let res = await deletePosition(data)
		return res
	},
	// 添加岗位名称
	async addPosition({commit}, data){
		let res = await addPosition(data)
		return res
	}
}
 
export default {
	namespaced: true,
	state,
	mutations,
	actions
}